package com.lucky.common.service;

import com.lucky.common.base.BaseService;
import com.lucky.common.cache.RightCache;
import com.lucky.common.mapper.PermMapper;
import com.lucky.common.mapper.RoleMapper;
import com.lucky.common.mapper.UserMapper;
import com.lucky.common.pojo.po.UserPO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class UserService extends BaseService<UserMapper,UserPO> {

	public Logger log = LoggerFactory.getLogger(UserService.class);
	
	@Resource
	UserMapper userMapper;

	@Resource
	RoleMapper roleMapper;

	@Resource
	RightCache rightCache;

	@Resource
	PermMapper privMapper;

	
	public List<UserPO> getUserByOrgId(Long orgId){
		return userMapper.getUserByOrgId(orgId);
	}
	

	public UserPO getUser(String userCode){
		return userMapper.getUserByUserCode(userCode);
	}
	

	public List<String> queryRoles(String userCode){
        return roleMapper.queryRoles(userCode);
	}

	public List<String> queryRoleNames(String userCode){
        return roleMapper.queryRoleNames(userCode);
	}
	
	public String getUserSession (String userCode){
        return userMapper.getUserSession(userCode);
	}

	public UserPO loadUserByUsernameAndPassword(String username, String password){
		return userMapper.getUserByNameAndPwd(username, password);
	}


}
